﻿using DXApplicationTangche.UC.下单MTO.Service;
using DXApplicationTangche.UC.项目成果管理.service;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace DXApplicationTangche.UC.下单MTO
{
    public partial class FormMTO下单提交预览 : DevExpress.XtraEditors.XtraForm
    {
        private SaleOrderRequestFacadeDTO saleOrderRequestFacadeDTO = new SaleOrderRequestFacadeDTO();
        public FormMTO下单提交预览(SaleOrderRequestFacadeDTO saleOrderRequestFacadeDTO)
        {
            InitializeComponent();
            this.saleOrderRequestFacadeDTO = saleOrderRequestFacadeDTO;
            this.gridControl订单预览.DataSource = saleOrderRequestFacadeDTO.saleOrderDetailRequestDTOList;
            this.gridView订单预览.RefreshData();
        }

        private void textBox销售确认扫码_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyValue == 13)
            {
                try
                {
                    if (String.IsNullOrEmpty(this.textBox销售确认扫码.Text))
                    {
                        MessageBox.Show("无扫描信息");
                        return;
                    }
                    //判断扫描的工牌是否正确
                    String mnemonic = 项目成果Service.get判断扫描员工码是否正确(this.textBox销售确认扫码.Text.Trim());
                    if (String.IsNullOrWhiteSpace(mnemonic))
                    {
                        this.textBox销售确认扫码.Clear();
                        MessageBox.Show("扫描员工码错误，请重新扫描");
                        return;
                    }
                    else
                    {
                        MTO订单Service.createSaleOrderAndSaveRecordeSaleOrder(this.textBox销售确认扫码.Text.Trim(), saleOrderRequestFacadeDTO);
                        MessageBox.Show("下单成功");
                    }
                    this.Close();
                }
                catch (Exception exception)
                {
                    MessageBox.Show(exception.Message);
                }

            }
        }
    }
}
